import "./index.less";
import {defineComponent} from "vue";

interface ISearchWeight {
}

interface ISearchProps {

}


export const SearchBody = defineComponent({
    name: "yf-search-body",
    render() {
        let children = this.$slots?.default && this.$slots?.default() || []
        // @ts-ignore
        return (<div class="yfht-search-form-body">
            {children}
        </div>)
    }
})

export const SearchAction = defineComponent({
    name: "yf-search-action",
    render() {
        let children = this.$slots?.default && this.$slots?.default() || []
        return (<div class="yfht-search-form-actions">
            <a-button type={"primary"}>查询</a-button>
            <a-button>重置</a-button>
            {children}
        </div>)
    }
})

export const Search = defineComponent({
    name: "yf-search",
    components: {
        SearchBody,
        SearchAction
    },
    render() {
        let children = this.$slots?.default && this.$slots?.default() || [];
        return (<div class="yfht-search">
            {(Array.isArray(children) && children.length > 1) ? children.filter(item => (item.type as { name: string })?.name === "yf-search-body") : children}
            {(Array.isArray(children) && children.length > 1) ?
                children.filter(item => (item.type as { name: string })?.name === "yf-search-action") :
                <SearchAction></SearchAction>}
        </div>)
    }
})





